<?php


namespace app\queue\stomp;


use app\queue\BaseConsumer;
use common\service\TaskStatisticsService;

/**
 * 同步概念的关联关系到资产和关卡中去
 * Class SyncDesignRelationData
 * @package app\queue\redis
 */
class GenerateTaskStatisticsCache extends BaseConsumer
{

    // 要消费的队列名
    public $queue = 'generate_task_statistics_cache';

    // 连接名，对应 config/redis_queue.php 里的连接`
    public $connection = 'default';

    /**
     * @param $data
     * @return void
     */
    public function doConsume($data)
    {
        try {
            $taskStatisticsService = new TaskStatisticsService();
            if ($data['project_id'] > 0) {
                $taskStatisticsService->generateProjectEpisodeTaskStatisticsAction($data['project_id']);
            }
        } catch (\Throwable $e) {
            trace(format_exception_info($e), 'ERR');
        }
    }
}
